package com.ego.controller;

import com.ego.dao.UserInfoDao;
import com.ego.dao.impl.UserInfoDaoImpl;
import com.ego.vo.UserInfoVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author 袁梦达 2019012364
 */
@WebServlet("/UserInfoServlet")
public class UserInfoServlet extends HttpServlet {

    private UserInfoDao userInfoDao = new UserInfoDaoImpl();

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        UserInfoVo userInfoVo = userInfoDao.getUserInfo(String.valueOf(getServletContext().getAttribute("userNumber")));
        String msg = userInfoVo.getUserNumber() + "," + userInfoVo.getNickName();
        response.getWriter().print(msg);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
